package com.qianfeng.smartplatform.event.listener;/*
 *@Description:
 *@author:赵健
 *@Date:zjzzz 2022/9/13 20:10
 */

import com.qianfeng.smartplatform.event.DeviceStatusEvent;
import com.qianfeng.smartplatform.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DevliceStatusListener {
    @Autowired
    private DeviceService deviceService;

    public void onStatusChange(DeviceStatusEvent event) {
        deviceService.updateDeviceStatus(event.getDeviceId(), event.getStatus() == DeviceStatusEvent.Status.OFFLINE ? 0 : 1);
    }
}
